//
//  WLRouterBingFlowController.m
//  WanLian
//
//  Created by muzhuang on 2018/9/17.
//  Copyright © 2018年 wanlian. All rights reserved.
//

#import "WLRouterBingFlowController.h"
#import "WLScanBindingRouterController.h"
#import "WLRouterNetworkSetController.h"
#import "WLWebViewController.h"

@interface WLRouterBingFlowController ()
{
    UIView  *vFirstFlow;
    UIImageView *ivBinding;
    UIImageView *ivFirstTick;
    UIView  *vFirstLine;
    
    UIView  *vSecondFlow;
    UIImageView *ivWifi;
    UIImageView *ivSecondTick;
    UIView  *vSecondLine;
    
    UIView  *vThirdFlow;
    UIImageView *ivSetting;
    UIImageView *ivThirdTick;
    
    UIButton    *btnSetting;
    UIView      *topView;
}

//@property (nonatomic, assign) NSInteger flowStatus;

@end

@implementation WLRouterBingFlowController

//- (void)viewWillAppear:(BOOL)animated
//{
//    [super viewWillAppear:animated];
//    if (_flowStatus==1||_flowStatus==2)
//    {
//        if (_flowStatus==1) {
//            [self flowFinishedStatus:1];
//        }
//        NSString *wifiStr = [WLCommonTool getWifiSSID];
//        if ([wifiStr hasPrefix:@"TianYiLianWiFi"]) {
//            _flowStatus = 2;
//            [self flowFinishedStatus:2];
//        }
//        else
//        {
//            topView.hidden = NO;
//            if (_flowStatus==2) {
//                _flowStatus = 1;
//                [self flowFinishedStatus:1];
//            }
//        }
//    }
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.fd_prefersNavigationBarHidden = YES;
    self.fd_interactivePopDisabled = _isPopDisabled;
    
    UIView *topGradientView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH_SCREEN_WL, WLScaleX(236))];
//    topGradientView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:topGradientView];
    CAGradientLayer *gradientView = [CAGradientLayer layer];
    gradientView.frame = topGradientView.bounds;
    gradientView.colors = @[(__bridge id)wlUIColorRGB(0x238DF1).CGColor,(__bridge id)wlUIColorRGB(0x22C2EC).CGColor];
    gradientView.startPoint = CGPointMake(0, 0);
    gradientView.endPoint = CGPointMake(1, 0);
    [topGradientView.layer addSublayer:gradientView];
    
//    CAShapeLayer *cornerLayer = [CAShapeLayer layer];
//    UIBezierPath *cornerPath = [UIBezierPath bezierPathWithRoundedRect:topGradientView.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(130, 20)];
//    cornerLayer.path = cornerPath.CGPath;
//    cornerLayer.frame = topGradientView.bounds;
////    [topGradientView.layer addSublayer:cornerLayer];
//    topGradientView.layer.mask = cornerLayer;
    
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, WIDTH_SCREEN_WL, WLScaleX(210))];
    [path1 moveToPoint:CGPointMake(0, WLScaleX(210))];
    CGPoint end1Point = CGPointMake(WIDTH_SCREEN_WL, WLScaleX(210));
    [path1 addQuadCurveToPoint:end1Point controlPoint:CGPointMake(WIDTH_SCREEN_WL/2.0, WLScaleX(280))]; // 二次贝塞尔曲线
    CAShapeLayer *path1Layer = [CAShapeLayer layer];
    path1Layer.frame = topGradientView.bounds;
    path1Layer.lineWidth = 1;
    path1Layer.strokeColor = [UIColor blueColor].CGColor;
//    path1Layer.fillColor = [UIColor redColor].CGColor; // 默认为blackColor
    path1Layer.path = path1.CGPath;
    topGradientView.layer.mask = path1Layer;
    
    UIImageView *ivFlowTip = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH_SCREEN_WL-76, WLScaleX(59), 76, 130)];
    ivFlowTip.image = [UIImage imageNamed:@"flow_top"];
    [topGradientView addSubview:ivFlowTip];
    
    UILabel *labWelcome = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(16), WLScaleX(95), 80, 30)];
    labWelcome.font = [WLCommonTool fontTypePingFangSCRegular:18];
    labWelcome.textColor = [UIColor whiteColor];
    labWelcome.text = @"欢迎来到";
    [topGradientView addSubview:labWelcome];
    
    UILabel *labRouter = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(labWelcome.frame)+5, WLScaleX(95), 120, 30)];
    labRouter.textAlignment = NSTextAlignmentCenter;
    labRouter.backgroundColor = [UIColor whiteColor];
    labRouter.font = [WLCommonTool fontTypePingFangSCMedium:18];
    labRouter.textColor = wlUIColorRGB(0x29A8FA);
    labRouter.text = @"天翼链路由器";
    [topGradientView addSubview:labRouter];
    labRouter.layer.cornerRadius = 5;
    labRouter.layer.masksToBounds = YES;
    
    UILabel *labTip = [[UILabel alloc] init];
    labTip.numberOfLines = 0;
    labTip.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labTip.textColor = [UIColor whiteColor];
    labTip.text = @"天翼链路由器是一款可以帮您赚钱的路由器,请先对其进行绑定，以开启智能路由新生活！";
    [topGradientView addSubview:labTip];
    [labTip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topGradientView.mas_top).offset(WLScaleX(146));
        make.left.equalTo(topGradientView.mas_left).offset(WLScaleX(16));
        make.right.equalTo(topGradientView.mas_right).offset(-WLScaleX(16));
    }];
    
    //流程底view
    [self flowViewSet];
    
    btnSetting = [[UIButton alloc] initWithFrame:CGRectMake(WLScaleX(32), WLScaleX(410+40), WIDTH_SCREEN_WL-WLScaleX(64), 47)];
    CAGradientLayer *gradientBtn = [CAGradientLayer layer];
    gradientBtn.frame = btnSetting.bounds;  // 设置显示的frame
    gradientBtn.colors = @[(__bridge id)wlUIColorRGB(0x1A59E2).CGColor,(__bridge id)wlUIColorRGB(0x2292F5).CGColor]; // 设置渐变颜色
    gradientBtn.startPoint = CGPointMake(0, 0);
    gradientBtn.endPoint = CGPointMake(1, 0);
    [btnSetting.layer insertSublayer:gradientBtn atIndex:0];
    
    btnSetting.layer.cornerRadius = 5;//WLScaleX(5);
    btnSetting.layer.masksToBounds = YES;
    btnSetting.titleLabel.font = [WLCommonTool fontTypePingFangSCMedium:16];
    [btnSetting setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btnSetting setTitle:@"绑定设备" forState:UIControlStateNormal];
    [btnSetting addTarget:self action:@selector(bindingAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnSetting];
    
    if (_isPopDisabled == NO) {
        UIButton *btnBack = [[UIButton alloc] initWithFrame:CGRectMake((WIDTH_SCREEN_WL-80)/2.0, CGRectGetMaxY(btnSetting.frame)+5, 80, 40)];
        
        btnBack.titleLabel.font = [WLCommonTool fontTypePingFangSCRegular:12];
        [btnBack setTitleColor:wlDarkGrayColor forState:UIControlStateNormal];
        [btnBack setTitle:@"以后再说" forState:UIControlStateNormal];
        [btnBack addTarget:self action:@selector(setBackAction) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btnBack];
    } else {
        UIButton *btnBack = [[UIButton alloc] initWithFrame:CGRectMake((WIDTH_SCREEN_WL-80)/2.0, CGRectGetMaxY(btnSetting.frame)+5, 80, 40)];
        
        btnBack.titleLabel.font = [WLCommonTool fontTypePingFangSCRegular:12];
        [btnBack setTitleColor:wlDarkGrayColor forState:UIControlStateNormal];
        [btnBack setTitle:@"切换账号" forState:UIControlStateNormal];
        [btnBack addTarget:self action:@selector(gotoLoginViewController) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btnBack];
    }
}
- (void)gotoLoginViewController {
    [WLCommonTool fourceGoToLogin];
    if (self.navigationController) {
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
//    [self setBackAction];
}
- (void)setBackAction
{
    if (_isPresented) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }
    else
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)flowViewSet
{
    UIView *flowView = [[UIView alloc] initWithFrame:CGRectMake(WLScaleX(16), WLScaleX(194), WIDTH_SCREEN_WL-WLScaleX(32), WLScaleX(216))];
    flowView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:flowView];
    flowView.layer.cornerRadius = 5;
//    flowView.layer.masksToBounds = YES;
    flowView.layer.shadowColor = wlRGBACOLOR(240, 240, 240, 0.5).CGColor;
    flowView.layer.shadowOffset = CGSizeMake(-5, 5);
    flowView.layer.shadowOpacity = 0.5;
    flowView.layer.shadowRadius = 5;
    
    UILabel *labFirst = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(30), 100, 20)];
    labFirst.font = [WLCommonTool fontTypePingFangSCMedium:14];
    labFirst.textColor = wlBlackColor;
    labFirst.text = @"1.网络配置";
    [flowView addSubview:labFirst];
    
    UILabel *lab1Sub = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(30)+20, WIDTH_SCREEN_WL-WLScaleX(32+40+5), 20)];
    lab1Sub.font = [WLCommonTool fontTypePingFangSCRegular:12];
    lab1Sub.textColor = wlLightTextColor;
    [flowView addSubview:lab1Sub];
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"1.用PC搜寻并连接前缀名为“TianYiLian”的WiFi"];
    [attStr addAttribute:NSFontAttributeName
                   value:[WLCommonTool fontTypePingFangSCMedium:12]
                   range:NSMakeRange(15, attStr.length-21)];
    [attStr addAttribute:NSForegroundColorAttributeName
                   value:wlDarkGrayColor
                   range:NSMakeRange(15, attStr.length-21)];
    lab1Sub.attributedText = attStr;
    //1.用PC搜寻并连接前缀名为“TianYiLIan”的WiFi
//    2.打开浏览器访问 192.168.1.1
    
    UILabel *lab2Sub = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(30)+40, 200, 20)];
    lab2Sub.font = [WLCommonTool fontTypePingFangSCRegular:12];
    lab2Sub.textColor = wlLightTextColor;
    lab2Sub.text = @"";
    [flowView addSubview:lab2Sub];
    NSMutableAttributedString *att2Sub = [[NSMutableAttributedString alloc] initWithString:@"2.打开浏览器访问 192.168.188.1"];
    [att2Sub addAttribute:NSFontAttributeName
                   value:[WLCommonTool fontTypePingFangSCMedium:12]
                   range:NSMakeRange(10, att2Sub.length-10)];
    [att2Sub addAttribute:NSForegroundColorAttributeName
                   value:wlDarkGrayColor
                   range:NSMakeRange(10, att2Sub.length-10)];
    lab2Sub.attributedText = att2Sub;
    
    UILabel *labHelp = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(30)+60, 80, 20)];
    labHelp.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labHelp.textColor = wlblueColor;
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"查看帮助" attributes:@{NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]}];
//    [attrStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(1, 6)];
    labHelp.attributedText = attrStr;
    [flowView addSubview:labHelp];
    
    UIButton *btnHelp = [[UIButton alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(30)+60, 80, 20)];
    [btnHelp addTarget:self action:@selector(routerSettingHelpAction) forControlEvents:UIControlEventTouchUpInside];
    [flowView addSubview:btnHelp];
    
    UILabel *labSecond = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(145), 100, 20)];
    labSecond.font = [WLCommonTool fontTypePingFangSCMedium:14];
    labSecond.textColor = wlBlackColor;
    labSecond.text = @"2.绑定设备";
    [flowView addSubview:labSecond];
    
    UILabel *labSecondSub = [[UILabel alloc] initWithFrame:CGRectMake(WLScaleX(40), WLScaleX(145)+20, WIDTH_SCREEN_WL-WLScaleX(32+40+5), 20)];
    labSecondSub.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labSecondSub.textColor = wlLightTextColor;
    labSecondSub.text = @"扫描路由器机身二维码";
    [flowView addSubview:labSecondSub];
    /*
    UIView *flowView = [[UIView alloc] initWithFrame:CGRectMake(WLScaleX(16), WLScaleX(194), WIDTH_SCREEN_WL-WLScaleX(32), WLScaleX(258))];
    flowView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:flowView];
//    WLWkSelf
//    [flowView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.view.mas_top).offset(WLScaleX(194));
//        make.left.equalTo(weakSelf.view.mas_left).offset(WLScaleX(16));
//        make.right.equalTo(weakSelf.view.mas_right).offset(-WLScaleX(16));
//        make.height.equalTo(@(WLScaleX(258)));
//    }];
    flowView.layer.cornerRadius = 5;
//    flowView.layer.masksToBounds = YES;
    flowView.layer.shadowColor = wlRGBACOLOR(240, 240, 240, 0.5).CGColor;
    flowView.layer.shadowOffset = CGSizeMake(-5, 5);
    flowView.layer.shadowOpacity = 0.5;
    flowView.layer.shadowRadius = 5;
    
    //first flow
    vFirstFlow = [[UIView alloc] initWithFrame:CGRectMake(WLScaleX(22), WLScaleX(30), 36, 36)];
    vFirstFlow.layer.cornerRadius = 18;
    vFirstFlow.layer.masksToBounds = YES;
    vFirstFlow.layer.borderWidth = WLScaleX(1);
    vFirstFlow.layer.borderColor = wlUnderlineColor.CGColor;
    [flowView addSubview:vFirstFlow];

    ivBinding = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flow_bindingNo"]];
    ivBinding.center = vFirstFlow.center;
    [flowView addSubview:ivBinding];

    UILabel *labBinding = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vFirstFlow.frame)+10, CGRectGetMinY(vFirstFlow.frame)-2, 65, 20)];
    labBinding.font = [WLCommonTool fontTypePingFangSCMedium:14];
    labBinding.textColor = wlBlackColor;
    labBinding.text = @"绑定设备";
    [flowView addSubview:labBinding];
    
    ivFirstTick = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick_finished"]];
    ivFirstTick.center = CGPointMake(CGRectGetMaxX(labBinding.frame)+10, CGRectGetMidY(labBinding.frame));
    [flowView addSubview:ivFirstTick];
    ivFirstTick.hidden = YES;

    UILabel *labBindNote = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vFirstFlow.frame)+10, CGRectGetMaxY(labBinding.frame), CGRectGetWidth(flowView.frame)-CGRectGetMaxX(vFirstFlow.frame)-15, 20)];
    labBindNote.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labBindNote.textColor = wlLightTextColor;
    labBindNote.text = @"扫描路由器机身二维码";
    [flowView addSubview:labBindNote];
    
    vFirstLine = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMidX(vFirstFlow.frame)-1, CGRectGetMaxY(vFirstFlow.frame), 2, WLScaleX(50))];
    vFirstLine.backgroundColor = wlUnderlineColor;
    [flowView addSubview:vFirstLine];
    
    //second
    vSecondFlow = [[UIView alloc] initWithFrame:CGRectMake(WLScaleX(22), CGRectGetMaxY(vFirstFlow.frame)+WLScaleX(50), 36, 36)];
    vSecondFlow.layer.cornerRadius = 18;
    vSecondFlow.layer.masksToBounds = YES;
    vSecondFlow.layer.borderWidth = WLScaleX(1);
    vSecondFlow.layer.borderColor = wlUnderlineColor.CGColor;
    [flowView addSubview:vSecondFlow];
    
    ivWifi = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flow_wifiNo"]];
    ivWifi.center = vSecondFlow.center;
    [flowView addSubview:ivWifi];

    UILabel *labWifi = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vSecondFlow.frame)+10, CGRectGetMinY(vSecondFlow.frame)-2, 65, 20)];
    labWifi.font = [WLCommonTool fontTypePingFangSCMedium:14];
    labWifi.textColor = wlBlackColor;
    labWifi.text = @"连接WiFi";
    [flowView addSubview:labWifi];
    
    topView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vSecondFlow.frame)+10+65, CGRectGetMinY(labWifi.frame), flowView.frame.size.width-75-labWifi.frame.origin.x, 20)];
    topView.backgroundColor = [UIColor clearColor];
    [flowView addSubview:topView];
    
    UIImageView *ivTip = [[UIImageView alloc] initWithFrame:CGRectMake(0, 2, 16, 16)];
    ivTip.image = [UIImage imageNamed:@"lab_headTip"];
    [topView addSubview:ivTip];
    
    UILabel *labScore = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 150, 20)];
    labScore.font = [WLCommonTool fontTypePingFangSCRegular:11];
    labScore.textColor = wlRedColor;
    labScore.text = @"请连接TianYiLianWiFi";
    [topView addSubview:labScore];
    topView.hidden = YES;

    ivSecondTick = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick_finished"]];
    ivSecondTick.center = CGPointMake(CGRectGetMaxX(labWifi.frame)+10, CGRectGetMidY(labWifi.frame));
    [flowView addSubview:ivSecondTick];
    ivSecondTick.hidden = YES;

    UILabel *labWifiNote = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vSecondFlow.frame)+10, CGRectGetMaxY(labWifi.frame), CGRectGetWidth(flowView.frame)-CGRectGetMaxX(vSecondFlow.frame)-15, 20)];
    labWifiNote.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labWifiNote.textColor = wlLightTextColor;
//    labWifiNote.text = @"请先将手机连接至TianYiLianWiFi";
    [flowView addSubview:labWifiNote];
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"请先将手机连接至TianYiLianWiFi"];
    [attStr addAttribute:NSFontAttributeName
                   value:[WLCommonTool fontTypePingFangSCMedium:12]
                   range:NSMakeRange(8, attStr.length-8)];
    [attStr addAttribute:NSForegroundColorAttributeName
                   value:wlBlackColor
                   range:NSMakeRange(8, attStr.length-8)];
    labWifiNote.attributedText = attStr;
    
    vSecondLine = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMidX(vSecondFlow.frame)-1, CGRectGetMaxY(vSecondFlow.frame), 2, WLScaleX(50))];
    vSecondLine.backgroundColor = wlUnderlineColor;
    [flowView addSubview:vSecondLine];
    
    //third flow
    vThirdFlow = [[UIView alloc] initWithFrame:CGRectMake(WLScaleX(22), CGRectGetMaxY(vSecondFlow.frame)+WLScaleX(50), 36, 36)];
    vThirdFlow.layer.cornerRadius = 18;
    vThirdFlow.layer.masksToBounds = YES;
    vThirdFlow.layer.borderWidth = WLScaleX(1);
    vThirdFlow.layer.borderColor = wlUnderlineColor.CGColor;
    [flowView addSubview:vThirdFlow];
    
    ivSetting = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flow_ipsettingNo"]];
    ivSetting.center = vThirdFlow.center;
    [flowView addSubview:ivSetting];
    
    UILabel *labSetting = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vThirdFlow.frame)+10, CGRectGetMinY(vThirdFlow.frame)-2, 65, 20)];
    labSetting.font = [WLCommonTool fontTypePingFangSCMedium:14];
    labSetting.textColor = wlBlackColor;
    labSetting.text = @"网络配置";
    [flowView addSubview:labSetting];
    
    ivThirdTick = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tick_finished"]];
    ivThirdTick.center = CGPointMake(CGRectGetMaxX(labSetting.frame)+10, CGRectGetMidY(labSetting.frame));
    [flowView addSubview:ivThirdTick];
    ivThirdTick.hidden = YES;
    
    UILabel *labSettingNote = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(vSecondFlow.frame)+10, CGRectGetMaxY(labSetting.frame), CGRectGetWidth(flowView.frame)-CGRectGetMaxX(vSecondFlow.frame)-15, 20)];
    labSettingNote.font = [WLCommonTool fontTypePingFangSCRegular:12];
    labSettingNote.textColor = wlLightTextColor;
    labSettingNote.text = @"完成相关网络配置，让路由器连接Intenet";
    [flowView addSubview:labSettingNote];
    */
}

- (void)routerSettingHelpAction
{
    WLWebViewController *webView = [[WLWebViewController alloc] init];
//    webView.urlStr = @"http://47.75.195.106/help/usehelp.html";
    webView.urlStr = [NSString stringWithFormat:@"%@/help/usehelp.html",[WLCommonTool getWebHost]];
//    webView.titleStr = @"";
    [self.navigationController pushViewController:webView animated:YES];
}

- (void)flowFinishedStatus:(NSInteger)finishedStep
{
    switch (finishedStep) {
        case 1:
        {
            vFirstFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vFirstFlow.layer.borderWidth = 0;
            ivBinding.image = [UIImage imageNamed:@"flow_binding"];
            ivFirstTick.hidden = NO;
            [btnSetting setTitle:@"去连接WiFi" forState:UIControlStateNormal];
            topView.hidden = YES;
        }
            break;
        case 2:
        {
            vFirstFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vFirstFlow.layer.borderWidth = 0;
            ivBinding.image = [UIImage imageNamed:@"flow_binding"];
            ivFirstTick.hidden = NO;
            vFirstLine.backgroundColor = wlUIColorRGB(0x29A8FA);
            vSecondFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vSecondFlow.layer.borderWidth = 0;
            ivWifi.image = [UIImage imageNamed:@"flow_wifi"];
            ivSecondTick.hidden = NO;
            topView.hidden = YES;
            [btnSetting setTitle:@"立即配置" forState:UIControlStateNormal];
        }
            break;
        case 3:
        {
            vFirstFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vFirstFlow.layer.borderWidth = 0;
            ivBinding.image = [UIImage imageNamed:@"flow_binding"];
            ivFirstTick.hidden = NO;
            vFirstLine.backgroundColor = wlUIColorRGB(0x29A8FA);
            vSecondFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vSecondFlow.layer.borderWidth = 0;
            ivWifi.image = [UIImage imageNamed:@"flow_wifi"];
            ivSecondTick.hidden = NO;
            vSecondLine.backgroundColor = wlUIColorRGB(0x29A8FA);
            vThirdFlow.backgroundColor = wlUIColorRGB(0x29A8FA);
            vThirdFlow.layer.borderWidth = 0;
            ivSetting.image = [UIImage imageNamed:@"flow_ipsetting"];
            ivThirdTick.hidden = NO;
            topView.hidden = YES;
            [btnSetting setTitle:@"开启智能路由新生活" forState:UIControlStateNormal];
        }
            break;
            
        default:
            break;
    }
}

- (void)bindingAction
{
    
    WLScanBindingRouterController *scanController = [[WLScanBindingRouterController alloc] init];
    BOOL isdismiss = NO;
    if (_isPopToMain == YES) {
        isdismiss = NO;
    } else {
        isdismiss = _isPresented;
    }
    scanController.isDismiss = isdismiss;
    [self.navigationController pushViewController:scanController animated:YES];
    
    return;
    if (_flowStatus==0)
    {
        WLWkSelf
        WLScanBindingRouterController *scanController = [[WLScanBindingRouterController alloc] init];
        scanController.bindingSucc = ^{
            weakSelf.flowStatus = 1;
            [weakSelf flowFinishedStatus:1];
            NSString *wifiStr = [WLCommonTool getWifiSSID];
            if ([wifiStr hasPrefix:@"TianYiLianWiFi"]) {
                weakSelf.flowStatus = 2;
                [weakSelf flowFinishedStatus:2];
            }
        };
        [self.navigationController pushViewController:scanController animated:YES];
    }
    else if (_flowStatus==1)
    {

//        NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
//        if ([[UIApplication sharedApplication] canOpenURL:url])
//        {
//            [[UIApplication sharedApplication] openURL:url];
//        }
        NSURL*url = [NSURL URLWithString:@"App-Prefs:root=WIFI"];
        if (@available(iOS 10.0, *)) {
//                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
            [[UIApplication sharedApplication]openURL:url options:@{}completionHandler:^(BOOL success) {

            }];
        } else {
            [[UIApplication sharedApplication] openURL:url];
        }
    }
    else
    {
        WLRouterNetworkSetController *networkSetController = [[WLRouterNetworkSetController alloc] init];
        [self.navigationController pushViewController:networkSetController animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
